package generator.website;

import java.util.Iterator;
import org.eclipse.emf.common.util.EList;
import CarProject.*;
import CarProject.impl.*;
import org.eclipse.emf.ecore.EObject;;

public class CreationFormulaire
{
  protected static String nl;
  public static synchronized CreationFormulaire create(String lineSeparator)
  {
    nl = lineSeparator;
    CreationFormulaire result = new CreationFormulaire();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = NL + "<%@ page language=\"java\" contentType=\"text/html; charset=ISO-8859-1\"" + NL + "\tpageEncoding=\"ISO-8859-1\"%>" + NL + "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" + NL + "<%@ taglib prefix=\"html\" uri=\"http://struts.apache.org/tags-html\"%>" + NL + "<%@ taglib prefix=\"bean\" uri=\"http://struts.apache.org/tags-bean\"%>" + NL + "<%@ taglib prefix=\"nested\" uri=\"http://struts.apache.org/tags-nested\"%>" + NL + "" + NL + "" + NL + "" + NL + "<html:html><body>" + NL + "\t<html:form action=\"/";
  protected final String TEXT_2 = "\" method=\"post\">" + NL + "\t\t<table>" + NL + "\t\t\t";
  protected final String TEXT_3 = NL + "    \t<tr>" + NL + "    \t\t<td align=\"right\">";
  protected final String TEXT_4 = "</td>" + NL + "    \t\t<td align=\"left\"><html:text property=\"";
  protected final String TEXT_5 = "\" size=\"30\" maxlength=\"30\" /></td>" + NL + "    \t</tr> " + NL + "    \t   \t" + NL + "    \t";
  protected final String TEXT_6 = "<tr><td align=\"right\">";
  protected final String TEXT_7 = NL + "    \t    \t<Input type=\"submit\" name=\"submit\" value=\"Ajouter\">" + NL + "    \t    \t";
  protected final String TEXT_8 = NL + "    \t    \t<Input type=\"submit\" name=\"submit\" value=\"Modifier\">" + NL + "    \t    \t";
  protected final String TEXT_9 = NL + "    \t    \t<Input type=\"submit\" name=\"submit\" value=\"Supprimer\">" + NL + "    \t    \t";
  protected final String TEXT_10 = NL + "    \t    \t<Input type=\"submit\" name=\"submit\" value=\"Lister\">" + NL + "    \t    \t";
  protected final String TEXT_11 = NL + "    \t    </td>" + NL + "    \t</tr>" + NL + "    \t</table>" + NL + "\t</html:form>" + NL + "</body></html:html>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    SiteWeb site = (SiteWeb) ((Object[]) argument)[0]; 
    TableImpl laTable=(TableImpl)site.getBasedonnees().getEstCompose().get(0);
    EList<Champs> listChamps = laTable.getPossede();
    String type=null;
    VueFormulaire formulaire=(VueFormulaire) ((Object[]) argument)[1];
    stringBuffer.append(TEXT_1);
    stringBuffer.append(formulaire.getNomVue());
    stringBuffer.append(TEXT_2);
    
		for(int i=0;i<listChamps.size();i++){
    stringBuffer.append(TEXT_3);
    stringBuffer.append(((ChampsImpl) listChamps.get(i)).getNom());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(((ChampsImpl) listChamps.get(i)).getNom()
    		);
    stringBuffer.append(TEXT_5);
    }
    	
    	    
    stringBuffer.append(TEXT_6);
    
    	    	if(formulaire.getPossedeAjouter()!=null){
    stringBuffer.append(TEXT_7);
    }
    
    	    	if(formulaire.getPossedeAction()!=null){
    stringBuffer.append(TEXT_8);
    }
    
    	    	if(formulaire.getPossedeSupprimer()!=null){
    stringBuffer.append(TEXT_9);
    }
    
    	    	if(formulaire.getPossedeList()!=null){
    stringBuffer.append(TEXT_10);
    }
    stringBuffer.append(TEXT_11);
    return stringBuffer.toString();
  }
}
